﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FredCK.FCKeditorV2;
using BLL.Faq;
using BLL;
using DTO;

public partial class ManageSupport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void EnableCheckBox()
    {
        Control chkShowYahoo = dvwSupport.FindControl("chkShowYahoo");
        if (chkShowYahoo != null)
        {
            CheckBox chkyahoo = chkShowYahoo as CheckBox;
            chkyahoo.Checked = true;
        }
        Control chkShowSkype = dvwSupport.FindControl("chkShowSkype");
        if (chkShowSkype != null)
        {
            CheckBox chkskype = chkShowSkype as CheckBox;
            chkskype.Checked = true;
        }
        Control chkVisible = dvwSupport.FindControl("chkVisible");
        if (chkVisible != null)
        {
            CheckBox chkvisible = chkVisible as CheckBox;
            chkvisible.Checked = true;
        }
    }

    protected void gvwSupports_SelectedIndexChanged(object sender, EventArgs e)
    {
        dvwSupport.ChangeMode(DetailsViewMode.Edit);
    }
    /// <summary>
    /// Load lại danh sách lĩnh vực sau khi xóa
    /// </summary>       
    ///
    protected void gvwSupports_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {
        gvwSupports.SelectedIndex = -1;
        gvwSupports.DataBind();
        dvwSupport.ChangeMode(DetailsViewMode.Insert);
    }
    /// <summary>
    /// Xử lý khi người dùng chọn xóa
    /// </summary>       
    protected void gvwSupports_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ImageButton btn = e.Row.Cells[7].Controls[0] as ImageButton;
            btn.OnClientClick = "if (confirm('Bạn muốn xóa thông tin này ?') == false) return false;";
        }
    }
    /// <summary>
    /// Load lại danh sách lĩh vực sau khi thêm
    /// </summary>       
    protected void dvwSupport_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
        gvwSupports.SelectedIndex = -1;
        gvwSupports.DataBind();

    }
    /// <summary>
    /// Load lại danh sách lĩnh vực sau khi cập nhật
    /// </summary>       
    protected void dvwSupport_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {
        gvwSupports.SelectedIndex = -1;
        gvwSupports.DataBind();
    }
    /// <summary>
    /// Gán giá trị mặc định cho txtImportance (control con của dvwSupport) là 0
    /// </summary>       
    protected void dvwSupport_ItemCreated(object sender, EventArgs e)
    {

    }
    /// <summary>
    /// Load lại danh sách lĩnh vực khi người dùng hủy bỏ thao tác
    /// </summary>       
    protected void dvwSupport_ItemCommand(object sender, DetailsViewCommandEventArgs e)
    {
        if (e.CommandName == "Cancel")
        {
            gvwSupports.SelectedIndex = -1;
            gvwSupports.DataBind();
        }
    }
    protected void dvwSupport_ModeChanged(object sender, EventArgs e)
    {
        if (dvwSupport.CurrentMode == DetailsViewMode.Insert)
            EnableCheckBox();
    }
    protected void dvwSupport_ModeChanging(object sender, DetailsViewModeEventArgs e)
    {
        if (dvwSupport.CurrentMode == DetailsViewMode.Insert)
            EnableCheckBox();
    }
}
